﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lucene.Net.Analysis;
using System.IO;
namespace LWrap.CustomLWrapps
{
    public class StemmerBase
    {
        private Analyzer _stemmer = null;

        public StemmerBase()
        {
            this._stemmer = new PorterStemStopAnalyzer();
        }

        protected string GetStemmedText(string text)
        {
            StringBuilder sb = new StringBuilder();
            StringReader reader = new StringReader(text);
            TokenStream stream = this._stemmer.TokenStream(null, reader);
            Token token = stream.Next();
            while (token != null)
            {
                sb.Append(token.TermText());
                token = stream.Next();
                if (token == null)
                    sb.Append(" ");
            }

            return sb.ToString();
        }
    }
}
